<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'password.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" href="css/page.css"/> 

<script type="text/javascript">
	
	function pag_nav(frm,pageInd){
		frm.pageIndex.value = pageInd;
		frm.submit();
	}
	function jump_to(frm, pageInput){
		var num=document.getElementById("totalPages").value;
		
		//用户输入的信息需要验证，其余与上一个方法功能一样
		//用户只能输入1-9的数字
		var regx = /^[1-9]\d*$/;
		if(!regx.test(pageInput)){
			alert("请重新输入正确的数字！");
			document.getElementById("inputPage").select();
		}else if((pageInput - num) > 0 ){
			alert("输入的数字必须在1和最大页码之间！请重新输入！");
			document.getElementById("inputPage").select();
		}else{
			pag_nav(frm, pageInput);
		}
	}
</script>
</head>
<body>
<input type="hidden" id="pageIndex" name="pageIndex" value="1"/>
<div class="page-bar">
			<ul class="page-num-ul clearfix">
				<li>共${param.totalCount}条记录&nbsp;&nbsp; ${param.pageIndex }/${param.totalPages }页</li>
				<c:if test= "${(param.pageIndex -1) > 0 }">
				  <a href="javascript:pag_nav(document.forms[0],1);">首页</a>
				  <a href="javascript:pag_nav(document.forms[0],${param.pageIndex-1 });">上一页</a>
				</c:if>
				<c:if test="${(param.pageIndex - param.totalPages) < 0}">
				  <a href="javascript:pag_nav(document.forms[0],${param.pageIndex+1 }); ">下一页</a>
				  <a href="javascript:pag_nav(document.forms[0],${param.totalPages });" >最后一页</a>&nbsp;&nbsp;
				</c:if>
			</ul>
		 <span class="page-go-form"><label>跳转至</label>
	     <input type="text" name="inputPage" id="inputPage" class="page-key" />页
	     <input type="hidden" id="totalPagea" value="${param.totalPages }"/>
	     <button type="button" class="page-btn" onClick="jump_to(document.forms[0],document.getElementById('inputPage').value)">GO</button>
		</span>
		</div> 
</body>
</html>